************************
* The limits of ‘Western’ supply chain sustainability governance to halt deforestation
* Lead Author: Christoph Kubitza
* Email: Christoph.Kubitza@giga-hamburg.de
* Date: 03.7.2025

***********************
* ANALYSIS
************************
clear all
set more off
version 16

**DESCRIPTIVES
**TABLE A1
      *** Set working directory and load data
      cd "C:\Users\christoph.kubitza\OneDrive - GIGA\Working Paper\CK Oil palm investors\Data\"
      use "04_master/master_data_v2.dta", replace

      *** Generate active area variables
      gen pixarea_ha_active = pixarea_ha if active_concession == 1
      gen pixarea_ha_peat_active = pixarea_ha_peat if active_concession == 1

      *** Define a reusable macro for post-collapse metrics
      program define gen_shares
      gen share_peat = pixarea_ha_peat / pixarea_ha
      gen share_peat_active = pixarea_ha_peat_active / pixarea_ha_active
      gen share_supply21 = pixarea_ha_w_supply21_dum / pixarea_ha
      gen share_supply20 = pixarea_ha_w_supply20_dum / pixarea_ha
      end

      *** === HIC Investors ===

      collapse (sum) pixarea_ha pixarea_ha_active pixarea_ha_peat_active pixarea_ha_gav ///
            pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum ///
            pixarea_ha_w_supply21_dum, by(investor_highinc_woSGP poly_id active_concession)

      collapse (sum) pixarea_ha pixarea_ha_active pixarea_ha_peat_active pixarea_ha_gav ///
            pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum ///
            pixarea_ha_w_supply21_dum (count) poly_id (sum) active_concession, by(investor_highinc_woSGP)

      gen_shares
      
      asdoc list poly_id pixarea_ha pixarea_ha_gav share_peat ///
            active_concession pixarea_ha_active share_peat_active, ///
            stat(N mean sd) dec(3) format(%12.3f) abb(.) label tzok ///
            save(06_tables\TableA1_des.rtf) replace


      *** === RSPO Analysis ===
      use "04_master/master_data_v2.dta", replace
      gen pixarea_ha_active = pixarea_ha if active_concession == 1
      gen pixarea_ha_peat_active = pixarea_ha_peat if active_concession == 1

      collapse (sum) pixarea_ha pixarea_ha_active pixarea_ha_peat_active pixarea_ha_gav ///
            pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum ///
            pixarea_ha_w_supply21_dum  , by(rspo_mill poly_id active_concession)
                  
      collapse (sum) pixarea_ha pixarea_ha_active pixarea_ha_peat_active pixarea_ha_gav ///
            pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum ///
            pixarea_ha_w_supply21_dum (count) poly_id (sum) active_concession, by(rspo_mill)

      gen_shares
      asdoc list poly_id pixarea_ha pixarea_ha_gav share_peat active_concession ///
            pixarea_ha_active share_peat_active, stat(N mean sd) dec(3) ///
            abb(.) label tzok append


      *** === Supply Chain Analysis ===
      use "04_master/master_data_v2.dta", replace
      gen pixarea_ha_active = pixarea_ha if active_concession == 1
      gen pixarea_ha_peat_active = pixarea_ha_peat if active_concession == 1

      collapse (sum) pixarea_ha pixarea_ha_active pixarea_ha_peat_active pixarea_ha_gav ///
            pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum ///
            pixarea_ha_w_supply21_dum, by(wsupply_2021_dum poly_id active_concession)
                  

      collapse (sum) pixarea_ha pixarea_ha_active pixarea_ha_peat_active pixarea_ha_gav ///
            pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum ///
            pixarea_ha_w_supply21_dum (count) poly_id  (sum) active_concession, ///
            by(wsupply_2021_dum)

      gen_shares
      asdoc list poly_id pixarea_ha pixarea_ha_gav share_peat active_concession ///
            pixarea_ha_active share_peat_active, stat(N mean sd) dec(3) ///
            abb(.) label tzok append

      collapse (sum) pixarea_ha pixarea_ha_active pixarea_ha_peat_active pixarea_ha_gav ///
            pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum ///
            pixarea_ha_w_supply21_dum (count) poly_id (sum) active_concession

      gen_shares
      asdoc list poly_id pixarea_ha pixarea_ha_gav share_peat active_concession ///
            pixarea_ha_active share_peat_active, stat(N mean sd) dec(3) ///
            abb(.) label tzok append


**Table A2 Appendix Cross tabulation 
      use "04_master/master_data_v2.dta", replace
      collapse (sum) pixarea_m2 , by( investor_highinc_woSGP rspo_mill wsupply_2021_dum)
      gen pixarea_ha= pixarea_m2/10000


***REGRESSIONS
*Specifications
      cd "C:\Users\christoph.kubitza\OneDrive - GIGA\Working Paper\CK Oil palm investors\Data\"
      use "04_master/master_data_v2.dta", replace

      global controls1 peat_d##wsupply_2020_dum srtm_alti road_acc att_yield
      global controls2 peat_d##wsupply_2021_dum srtm_alti road_acc att_yield
      global controls4 peat_d##investor_highinc_woSGP srtm_alti road_acc att_yield
      global controls5 peat_d##investor_west srtm_alti road_acc att_yield
      global controls7 peat_d##rspo_mill srtm_alti road_acc att_yield
      global controls8 peat_d##rspo_deal srtm_alti road_acc att_yield
      global controls10 peat_d##rspo_mill peat_d##investor_highinc_woSGP peat_d##wsupply_2021_dum  srtm_alti road_acc att_yield
      global controlsdes peat_d srtm_alti road_acc att_yield

*Table A3 With no filter
      eststo a3op11: areg op1317_share $controls4 opshare_2012 opshare_2012_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a3pl11: areg gav_1119_share $controls4  gavshare_2010 gavshare_2010_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a3tmf11: areg tmf_treeloss1121_share $controls4   tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a3gfc11: areg gfc_treeloss1121_share $controls4   gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a3rsop11: areg op1317_share $controls7 opshare_2012 opshare_2012_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a3rspl11: areg gav_1119_share $controls7  gavshare_2010 gavshare_2010_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a3rstmf11: areg tmf_treeloss1121_share $controls7   tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a3rsgfc11: areg gfc_treeloss1121_share $controls7   gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
   
      esttab a3* using "06_tables\TableA3.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors 2011-2020) label nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 

*Filter dataset
      *Drop deals with more than 1% OP already in 2000
      drop if gavshare_2000_poly_id>0.01      
      *With less then 1% of OP plating btw 2000 and 2019
      drop if gavshare_2019_poly_id<0.01  

**MAIN TABLES
*Table 1A
      eststo t2op11: areg op1317_share $controls4 opshare_2012 opshare_2012_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo t2pl11: areg gav_1119_share $controls4  gavshare_2010 gavshare_2010_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo t2tmf11: areg tmf_treeloss1121_share $controls4   tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo t2gfc11: areg gfc_treeloss1121_share $controls4   gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)

      esttab  t2* using "06_tables\Table1A.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors 2011-2020) label nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 

*Table 1B
      eststo t3op11: areg op1317_share $controls7 opshare_2012 opshare_2012_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo t3pl11: areg gav_1119_share $controls7  gavshare_2010 gavshare_2010_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo t3tmf11: areg tmf_treeloss1121_share $controls7   tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo t3gfc11: areg gfc_treeloss1121_share $controls7   gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)

      esttab t3*  using "06_tables\Table1B.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors 2011-2020) label nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 

*Table 1C
      eststo t4op11: areg op1317_share $controls2 opshare_2012 opshare_2012_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo t4pl11: areg gav_1119_share $controls2  gavshare_2010 gavshare_2010_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo t4tmf11: areg tmf_treeloss1121_share $controls2   tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo t4gfc11: areg gfc_treeloss1121_share $controls2   gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)

      esttab t4*  using "06_tables\Table1C.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors 2011-2020) label nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 


**APPENDIX Robustness checks
*Table A4 Buffer 10km
      eststo a4op11: areg op1317_share $controls4 opshare_2012 opshare_2012_sq  [fw= op_totpixel] if  peat_dis_km>-10 & peat_dis_km<10 , absorb( poly_id ) cluster( poly_id)
      eststo a4pl11: areg gav_1119_share $controls4  gavshare_2010 gavshare_2010_sq  [fw= gav_totalpixel] if  peat_dis_km>-10 & peat_dis_km<10 , absorb( poly_id ) cluster( poly_id)
      eststo a4tmf11: areg tmf_treeloss1121_share $controls4   tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-10 & peat_dis_km<10 , absorb( poly_id ) cluster( poly_id)
      eststo a4gfc11: areg gfc_treeloss1121_share $controls4   gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-10 & peat_dis_km<10 , absorb( poly_id ) cluster( poly_id)
      eststo a4rsop11: areg op1317_share $controls7 opshare_2012 opshare_2012_sq  [fw= op_totpixel] if  peat_dis_km>-10 & peat_dis_km<10 , absorb( poly_id ) cluster( poly_id)
      eststo a4rspl11: areg gav_1119_share $controls7  gavshare_2010 gavshare_2010_sq  [fw= gav_totalpixel] if  peat_dis_km>-10 & peat_dis_km<10 , absorb( poly_id ) cluster( poly_id)
      eststo a4rstmf11: areg tmf_treeloss1121_share $controls7   tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-10 & peat_dis_km<10 , absorb( poly_id ) cluster( poly_id)
      eststo a4rsgfc11: areg gfc_treeloss1121_share $controls7   gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-10 & peat_dis_km<10 , absorb( poly_id ) cluster( poly_id)

      esttab  a4* using "06_tables\TableA4.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors 2011-2020) label  nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 

*Table A5 anticpated effects
      eststo a5op11: areg op1217_share $controls4 opshare_2011 opshare_2011_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1, absorb( poly_id ) cluster( poly_id)
      eststo a5pl11: areg gav_1019_share $controls4  gavshare_2009 gavshare_2009_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a5tmf11: areg tmf_treeloss1021_share $controls4  tmf_forest_share_2009 tmf_forest_share_2009_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a5gfc11: areg gfc_treeloss1021_share $controls4  gfc_forestcover2010_share gfc_forestcover2010_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a5rsop11: areg op1217_share $controls7 opshare_2011 opshare_2011_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a5rspl11: areg gav_1019_share $controls7  gavshare_2009 gavshare_2009_sq   [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a5rstmf11: areg tmf_treeloss1021_share $controls7  tmf_forest_share_2009 tmf_forest_share_2009_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a5rsgfc11: areg gfc_treeloss1021_share $controls7  gfc_forestcover2010_share gfc_forestcover2010_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)

      esttab  a5*  using "06_tables\TableA5.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors 2011-2020) label nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 

*Table A6 Lagged effects
      eststo a6op11: areg op1417_share $controls4 opshare_2013 opshare_2013_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a6pl11: areg gav_1219_share $controls4  gavshare_2011 gavshare_2011_sq   [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a6tmf11: areg tmf_treeloss1221_share $controls4  tmf_forest_share_2011 tmf_forest_share_2011_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a6gfc11: areg gfc_treeloss1221_share $controls4  gfc_forestcover2012_share gfc_forestcover2012_share_sq   [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a6rsop11: areg op1417_share $controls7 opshare_2013 opshare_2013_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a6rspl11: areg gav_1219_share $controls7  gavshare_2011 gavshare_2011_sq   [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a6rstmf11: areg tmf_treeloss1221_share $controls7  tmf_forest_share_2011 tmf_forest_share_2011_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a6rsgfc11: areg gfc_treeloss1221_share $controls7  gfc_forestcover2012_share gfc_forestcover2012_share_sq   [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)

      esttab  a6*  using "06_tables\TableA6.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors 2011-2020) label nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 

*Table A7 Without KOR SGP 
      eststo a7op11: areg op1317_share $controls5 opshare_2012 opshare_2012_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a7pl11: areg gav_1119_share $controls5  gavshare_2010 gavshare_2010_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a7tmf11: areg tmf_treeloss1121_share $controls5   tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a7gfc11: areg gfc_treeloss1121_share $controls5   gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)

      esttab  a7* using "06_tables\TableA7.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors without Asian HIC countries) label  nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 

*Table A8 With RSPO deals 
      eststo a8op11: areg op1317_share $controls8 opshare_2012 opshare_2012_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a8pl11: areg gav_1119_share $controls8  gavshare_2010 gavshare_2010_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a8tmf11: areg tmf_treeloss1121_share $controls8   tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a8gfc11: areg gfc_treeloss1121_share $controls8   gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)

      esttab  a8* using "06_tables\TableA8.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors without Asian HIC countries) label  nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 

*Table A9 With supply chains dis 2020 
      eststo a9op11: areg op1317_share $controls1 opshare_2012 opshare_2012_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a9pl11: areg gav_1119_share $controls1  gavshare_2010 gavshare_2010_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a9tmf11: areg tmf_treeloss1121_share $controls1   tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a9gfc11: areg gfc_treeloss1121_share $controls1   gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)

      esttab  a9* using "06_tables\TableA9.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors without Asian HIC countries) label  nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 

*Table A10 Fire controls
      eststo a10tmf11: areg tmf_treeloss1121_share $controls4 fire_1121_share  tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a10gfc11: areg gfc_treeloss1121_share $controls4  fire_1121_share gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a10rstmf11: areg tmf_treeloss1121_share $controls7 fire_1121_share  tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a10rsgfc11: areg gfc_treeloss1121_share $controls7 fire_1121_share  gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
   
      esttab  a10tmf11 a10gfc11 a10rstmf11 a10rsgfc11 using "06_tables\TableA10.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Deforestation on peatlands with fire control 2011-2020) label nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 

*Table A11 all controls
      eststo a11op11: areg op1317_share $controls10 opshare_2012 opshare_2012_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a11pl11: areg gav_1119_share $controls10  gavshare_2010 gavshare_2010_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a11tmf11: areg tmf_treeloss1121_share $controls10   tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a11gfc11: areg gfc_treeloss1121_share $controls10   gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)

      eststo a11op12: areg op1317_share $controls10 opshare_2012 opshare_2012_sq  [fw= op_totpixel] if  peat_dis_km>-10 & peat_dis_km<10 , absorb( poly_id ) cluster( poly_id)
      eststo a11pl12: areg gav_1119_share $controls10  gavshare_2010 gavshare_2010_sq  [fw= gav_totalpixel] if  peat_dis_km>-10 & peat_dis_km<10 , absorb( poly_id ) cluster( poly_id)
      eststo a11tmf12: areg tmf_treeloss1121_share $controls10   tmf_forest_share_2010 tmf_forest_share_2010_sq [fw= tmf_totalpixel] if  peat_dis_km>-10 & peat_dis_km<10 , absorb( poly_id ) cluster( poly_id)
      eststo a11gfc12: areg gfc_treeloss1121_share $controls10   gfc_forestcover2011_share gfc_forestcover2011_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-10 & peat_dis_km<10 , absorb( poly_id ) cluster( poly_id)

      esttab  a11* using "06_tables\TableA11.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors without Asian HIC countries) label  nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 
  
 *Table A12 all controls     
      eststo a12op11: areg op1217_share $controls10 opshare_2011 opshare_2011_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a12pl11: areg gav_1019_share $controls10  gavshare_2009 gavshare_2009_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a12tmf11: areg tmf_treeloss1021_share $controls10  tmf_forest_share_2009 tmf_forest_share_2009_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a12gfc11: areg gfc_treeloss1021_share $controls10  gfc_forestcover2010_share gfc_forestcover2010_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)

      eststo a12op12: areg op1417_share $controls10 opshare_2013 opshare_2013_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a12pl12: areg gav_1219_share $controls10  gavshare_2011 gavshare_2011_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a12tmf12: areg tmf_treeloss1221_share $controls10  tmf_forest_share_2011 tmf_forest_share_2011_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a12gfc12: areg gfc_treeloss1221_share $controls10  gfc_forestcover2012_share gfc_forestcover2012_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)

      esttab  a12* using "06_tables\TableA12.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors without Asian HIC countries) label  nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 

*Table A13
      asdoc sum peat_d op1217_share op1317_share op1417_share op0212_share  gav_1019_share gav_1119_share gav_1219_share gav_0010_share  tmf_treeloss1021_share tmf_treeloss1121_share tmf_treeloss1221_share tmf_treeloss0010_share  gfc_treeloss1021_share gfc_treeloss1121_share gfc_treeloss1221_share gfc_treeloss0110_share   $controlsdes, by(investor_highinc_woSGP) stat(N mean sd) dec(3) abb(.) label tzok  save(06_tables\TableA13.rtf) replace
      asdoc sum peat_d op1217_share op1317_share op1417_share op0212_share  gav_1019_share gav_1119_share gav_1219_share gav_0010_share  tmf_treeloss1021_share tmf_treeloss1121_share tmf_treeloss1221_share tmf_treeloss0010_share  gfc_treeloss1021_share gfc_treeloss1121_share gfc_treeloss1221_share gfc_treeloss0110_share   $controlsdes, by(rspo_mill) stat(N mean sd) dec(3) abb(.) label tzok append
      asdoc sum peat_d op1217_share op1317_share op1417_share op0212_share  gav_1019_share gav_1119_share gav_1219_share gav_0010_share  tmf_treeloss1021_share tmf_treeloss1121_share tmf_treeloss1221_share tmf_treeloss0010_share  gfc_treeloss1021_share gfc_treeloss1121_share gfc_treeloss1221_share gfc_treeloss0110_share   $controlsdes, by(wsupply_2021_dum) stat(N mean sd) dec(3) abb(.) label tzok append

*Table A14 Before 2011 
      eststo a14op00: areg op0212_share $controls4 opshare_2001 opshare_2001_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a14pl00: areg gav_0010_share $controls4  gavshare_2000 gavshare_2000_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a14tmf00: areg tmf_treeloss0010_share $controls4  tmf_forest_share_2000  tmf_forest_share_2000_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a14gfc01: areg gfc_treeloss0110_share $controls4  gfc_forestcover2000_share gfc_forestcover2000_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a14rsop00: areg op0212_share $controls7 opshare_2001 opshare_2001_sq  [fw= op_totpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a14rspl00: areg gav_0010_share $controls7  gavshare_2000 gavshare_2000_sq  [fw= gav_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a14rstmf00: areg tmf_treeloss0010_share $controls7  tmf_forest_share_2000  tmf_forest_share_2000_sq [fw= tmf_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)
      eststo a14rsgfc01: areg gfc_treeloss0110_share $controls7  gfc_forestcover2000_share gfc_forestcover2000_share_sq  [fw= gfc_treeloss_totalpixel] if  peat_dis_km>-1 & peat_dis_km<1 , absorb( poly_id ) cluster( poly_id)

      esttab  a14* using "06_tables\TableA14.rtf", replace b(%8.3f) se(%8.3f) ///
      title(Palm planting and deforestation on peatlands by HIC investors without Asian HIC countries) label  nobaselevels noomitted ///
      star(* 0.10 ** 0.05 *** 0.01) addnotes(Notes: Standard errors clustered at deal level in parentheses. * p < 0.10, ** p < 0.05, *** p < 0.01) scalars(F r2  N) obslast nogap compress 


***FIGURES 
**FIGURE 2
*PANEL A
      use "04_master/master_data_panel_v2.dta", clear
      gen pixarea_000ha_op=(pixarea_m2*opncumshare_)/10000000
      gen pixarea_000ha_gav=(pixarea_m2*gavncumshare_)/10000000
      gen pixarea_000ha_tmf=(pixarea_m2*tmf_treeloss_share)/10000000
      gen gfc_treeloss_share=gfc_treeloss/gfc_treeloss_totalpixel
      gen pixarea_000ha_gfc=(pixarea_m2*gfc_treeloss_share)/10000000
      gen pixarea_millha=(pixarea_m2)/10000000000
      collapse (sum) pixarea_000ha_op pixarea_000ha_tmf pixarea_000ha_gfc pixarea_000ha_gav pixarea_millha op_exp tmf_treeloss tmf_totalpixel op_totpixel pixarea_m2 gfc_treeloss, by( peat_d  year)
     
      replace pixarea_000ha_op=. if year>=2018
      replace pixarea_000ha_tmf=. if year>=2022
      replace pixarea_000ha_gfc=. if year>=2022
      replace pixarea_000ha_gfc=. if year<=2000
      replace pixarea_000ha_gav=. if year>=2020
      drop if year>=2022
      gen id=1 if peat_d==0 
      replace id=2 if peat_d==1 
      xtset id year

      label var pixarea_000ha_op "Oil palm planting (Danylo)"
      label var pixarea_000ha_gav "Oil palm planting (Gaveau)"
      label var pixarea_000ha_gfc "Annual forest loss (GFC)"
      label var pixarea_000ha_tmf "Annual forest loss (TMF)"
      tsline pixarea_000ha_tmf pixarea_000ha_gfc  pixarea_000ha_op pixarea_000ha_gav if peat_d==0 & year>=2001, ytitle(Loss/Gain ('000ha)) ylabel(0 50 100) title(Outside peatland)  lcolor(dknavy  dkgreen sienna cranberry) lpattern(solid)
      graph save 05_figures/panel00.gph, replace 
      tsline  pixarea_000ha_tmf pixarea_000ha_gfc  pixarea_000ha_op pixarea_000ha_gav  if peat_d==1  & year>=2001, ytitle(Loss/Gain ('000ha)) ylabel(0 10 20) title(Within peatland)  lcolor(dknavy dkgreen sienna cranberry) lpattern(solid)
      graph save 05_figures/panel10.gph, replace 

      grc1leg    05_figures/panel00.gph 05_figures/panel10.gph,  cols(2) legendfrom(05_figures/panel00.gph )

      replace pixarea_000ha_gav=. if year<2000
      keep year peat_d pixarea_000ha_tmf pixarea_000ha_gfc  pixarea_000ha_op pixarea_000ha_gav
      export excel using "03_temp\Fig 2 Desc\Fig2_paneldata.xlsx", firstrow(varlabels) replace

*PANEL B
      **Investor wo SGP
      cd "C:\Users\christoph.kubitza\OneDrive - GIGA\Working Paper\CK Oil palm investors\Data\"
      use "04_master/master_data_v2.dta", replace
            collapse (sum)  pixarea_ha pixarea_ha_gav pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum pixarea_ha_w_supply21_dum  (max) active_concession  investor_highinc_woSGP (max) w_supply1721_condum (max)rspo_mill, by(poly_id investorname_highinc)
            gen type="HIC Inv." if investor_highinc_woSGP==1
            replace type="LMIC Inv." if investor_highinc_woSGP==0
            collapse (sum)  pixarea_ha pixarea_ha_gav, by(type)
            export excel using "03_temp\Fig 2 Desc\Fig2_data.xlsx", sheet("Tab1", modify) cell(A3) 

      **RSPO
      use "04_master/master_data_v2.dta", replace
            collapse (sum)  pixarea_ha pixarea_ha_gav pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum pixarea_ha_w_supply21_dum  (max) active_concession investor_highinc_wSGP (max) w_supply1721_condum (max)rspo_mill, by(poly_id investorname_highinc)
            gen type="RSPO" if rspo_mill==1
            replace type="W/o RSPO" if rspo_mill==0
            collapse (sum) pixarea_ha pixarea_ha_gav , by(type)
            export excel using "03_temp\Fig 2 Desc\Fig2_data.xlsx", sheet("Tab1", modify) cell(A5) 

      **Supply chain
      use "04_master/master_data_v2.dta", replace
            collapse (sum)  pixarea_ha pixarea_ha_gav pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum pixarea_ha_w_supply21_dum  (max) active_concession investor_highinc_wSGP (max) wsupply_2021_dum (max)rspo_mill, by(poly_id investorname_highinc)
            gen type=" MNE" if wsupply_2021_dum==1
            replace type="W/o MNE" if wsupply_2021_dum==0
            collapse (sum) pixarea_ha pixarea_ha_gav, by(type)
            export excel using "03_temp\Fig 2 Desc\Fig2_data.xlsx", sheet("Tab1", modify) cell(A7) 

      **INV active concessions
      use "04_master/master_data_v2.dta", replace
            collapse (sum)  pixarea_ha pixarea_ha_gav pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum pixarea_ha_w_supply21_dum  (max) active_concession  investor_highinc_woSGP (max) w_supply1721_condum (max)rspo_mill, by(poly_id investorname_highinc)
            gen type="HIC Investor" if investor_highinc_woSGP==1
            replace type="LMIC Investor" if investor_highinc_woSGP==0
            keep if active_concession==1
            collapse (sum) pixarea_ha pixarea_ha_peat pixarea_ha_nopeat  , by(type)
            gen share_peat= pixarea_ha_peat/pixarea_ha
            export excel using "03_temp\Fig 2 Desc\Fig2_data.xlsx", sheet("Tab1", modify) cell(A14) 

      **RSPO active concessions
      use "04_master/master_data_v2.dta", replace
            collapse (sum)  pixarea_ha pixarea_ha_gav pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum pixarea_ha_w_supply21_dum  (max) active_concession investor_highinc_wSGP (max) w_supply1721_condum (max)rspo_mill, by(poly_id investorname_highinc)
            gen type="RSPO" if rspo_mill==1
            replace type="W/o RSPO" if rspo_mill==0
            keep if active_concession==1
            collapse (sum) pixarea_ha pixarea_ha_peat pixarea_ha_nopeat  , by(type)
            gen share_peat= pixarea_ha_peat/pixarea_ha
            export excel using "03_temp\Fig 2 Desc\Fig2_data.xlsx", sheet("Tab1", modify) cell(A16) 

      **Supply chain active concessions
      use "04_master/master_data_v2.dta", replace
            collapse (sum)  pixarea_ha pixarea_ha_gav pixarea_ha_peat pixarea_ha_nopeat pixarea_ha_w_supply20_dum pixarea_ha_w_supply21_dum  (max) active_concession investor_highinc_wSGP (max) wsupply_2021_dum (max)rspo_mill, by(poly_id investorname_highinc)
            gen type="MNE" if wsupply_2021_dum==1
            replace type="W/o MNE" if wsupply_2021_dum==0
            keep if active_concession==1
            collapse (sum) pixarea_ha pixarea_ha_peat pixarea_ha_nopeat  , by(type)
            gen share_peat= pixarea_ha_peat/pixarea_ha
            export excel using "03_temp\Fig 2 Desc\Fig2_data.xlsx", sheet("Tab1", modify) cell(A18) 


**FIGURE 3
      cd "C:\Users\christoph.kubitza\OneDrive - GIGA\Working Paper\CK Oil palm investors\Data\"
      use "04_master/master_data_panel_v2.dta", clear
      keep poly_id pixel_id pixarea_m2 year peat_d rspo_mill wsupply_2021_dum investor_highinc_woSGP tmf_forest_share gavshare_
      keep if year==2000 | year==2019
      rename gavshare_ gav_oilpalm_share
      rename investor_highinc_woSGP inv_hic
      rename wsupply_2021_dum mne_2021_dum
      gen forest_dum=1 if tmf_forest_share>=0.5
      replace forest_dum=0 if gav_oilpalm_share>0 & gav_oilpalm_share!=.
      replace forest_dum=0 if  tmf_forest_share<0.5
      gen oilpalm_dum=1 if gav_oilpalm_share>0 & gav_oilpalm_share!=.
      replace oilpalm_dum=0 if gav_oilpalm_share==0 
      gen other_lu_dum=1 if tmf_forest_share<0.5 & gav_oilpalm_share==0
      replace other_lu_dum=0 if tmf_forest_share>=0.5 | (gav_oilpalm_share>0 & gav_oilpalm_share!=.)

      *Gen interaction terms
      gen forest_dum_nopeat= forest_dum
      replace forest_dum_nopeat=0 if peat_d==1
      gen forest_dum_peat=forest_dum
      replace forest_dum_peat=0 if peat_d==0

      gen other_lu_dum_nopeat= other_lu_dum
      replace other_lu_dum_nopeat=0 if peat_d==1
      gen other_lu_dum_peat=other_lu_dum
      replace other_lu_dum_peat=0 if peat_d==0

      foreach var of varlist inv_hic rspo_mill mne_2021_dum {
      gen oilpalm_dum_`var'=oilpalm_dum
      replace oilpalm_dum_`var'=0 if `var'==0
      }

      foreach var of varlist inv_hic rspo_mill mne_2021_dum {
      gen oilpalm_dum_no`var'=oilpalm_dum
      replace oilpalm_dum_no`var'=0 if `var'==1
      }

      foreach var of varlist oilpalm_dum_inv_hic oilpalm_dum_rspo_mill oilpalm_dum_mne_2021_dum oilpalm_dum_noinv_hic oilpalm_dum_norspo_mill oilpalm_dum_nomne_2021_dum {
      gen `var'_p=`var' if peat_d==1
      replace `var'_p=0 if peat_d==0
      }

      foreach var of varlist oilpalm_dum_inv_hic oilpalm_dum_rspo_mill oilpalm_dum_mne_2021_dum oilpalm_dum_noinv_hic oilpalm_dum_norspo_mill oilpalm_dum_nomne_2021_dum {
      gen `var'_np=`var' if peat_d==0
      replace `var'_np=0 if peat_d==1
      }

      foreach var of varlist forest_dum oilpalm_dum other_lu_dum forest_dum_nopeat forest_dum_peat other_lu_dum_nopeat other_lu_dum_peat oilpalm_dum_inv_hic* oilpalm_dum_rspo_mill* oilpalm_dum_mne_2021_dum* oilpalm_dum_noinv_hic* oilpalm_dum_norspo_mill* oilpalm_dum_nomne_2021_dum* {
      gen `var'_ha=`var'*pixarea_m2/10000
      }

      gen class_2000="Forest NoPeat" if forest_dum_nopeat==1
      replace class_2000="Forest Peat" if forest_dum_peat==1
      replace class_2000="Other LU NoPeat" if other_lu_dum_nopeat==1
      replace class_2000="Other LU Peat" if other_lu_dum_peat==1
      replace class_2000="Oil Palm RSPO x HIC x MNE" if oilpalm_dum_rspo_mill==1 & oilpalm_dum_inv_hic==1 & oilpalm_dum_mne_2021_dum==1
      replace class_2000="Oil Palm RSPO x MNE" if oilpalm_dum_rspo_mill==1 & oilpalm_dum_inv_hic==0 & oilpalm_dum_mne_2021_dum==1
      replace class_2000="Oil Palm RSPO x HIC" if oilpalm_dum_rspo_mill==1 & oilpalm_dum_inv_hic==1 & oilpalm_dum_mne_2021_dum==0
      replace class_2000="Oil Palm HIC x MNE" if oilpalm_dum_rspo_mill==0 & oilpalm_dum_inv_hic==1 & oilpalm_dum_mne_2021_dum==1
      replace class_2000="Oil Palm MNE" if oilpalm_dum_rspo_mill==0 & oilpalm_dum_inv_hic==0 & oilpalm_dum_mne_2021_dum==1
      replace class_2000="Oil Palm" if oilpalm_dum_rspo_mill==0 & oilpalm_dum_inv_hic==0 & oilpalm_dum_mne_2021_dum==0 & oilpalm_dum==1
      gen area_ha_2019= pixarea_m2/10000
      gen class_2019=class_2000[_n+1] if year==2000 & pixel_id==pixel_id[_n+1]
      drop if year==2019
      collapse (sum) area_ha_2019, by( class_2000 class_2019)
      drop if class_2019==""

      replace class_2000="Oil Palm" if class_2000=="Oil Palm*"
      replace class_2000="Oil Palm" if class_2000=="Oil Palm MNE"
      replace class_2000="Oil Palm" if class_2000=="Oil Palm RSPO x MNE"
      replace class_2000="Oil Palm" if class_2000=="Oil Palm RSPO x HIC x MNE"
      bysort class_2000: egen area_ha_2000=sum(area_ha_2019)
      order class_2000 area_ha_2000 class_2019 area_ha_2019

      export excel using "C:\Users\christoph.kubitza\OneDrive - GIGA\Working Paper\CK Oil palm investors\Data\03_temp\Fig 3 Sankey\Fig3_sankey_data_v2.xlsx", firstrow(variables) replace

**FIGURE 4 & 5
      clear all
      set more off
      version 16

      cd "C:\Users\christoph.kubitza\OneDrive - GIGA\Working Paper\CK Oil palm investors\Data\"
      use "04_master/master_data_v2.dta", replace

      **Filter dataset
      *Drop deals with more than 1% OP already in 2000
      drop if gavshare_2000_poly_id>0.01      
      *With less then 1% of OP plating btw 2000 and 2019
      drop if gavshare_2019_poly_id<0.01  
     
      *FIG4 A
      rdplot op1317_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==1, p(0) graph_options(ylabel(0(0.05)0.2) title("W HIC Investor (Danylo)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/ardplotop1.gph, replace 
      rdplot op1317_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==0, p(0) graph_options(ylabel(0(0.05)0.2) title("W/o HIC Investor (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/ardplotop2.gph, replace 
      rdplot gav_1119_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==1, p(0) graph_options(ylabel(0(0.2)0.6) title("W HIC Investor (Gaveau)", size(medsmall)) ytitle("Share of area with OP (0-1)" )  graphregion(color(white) lcolor(white)))
      graph save 05_figures/ardplotdu1.gph, replace 
      rdplot gav_1119_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==0, p(0) graph_options(ylabel(0(0.2)0.6) title("W/o HIC Investor (Gaveau)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/ardplotdu2.gph, replace 

      *FIG5 B
      rdplot tmf_treeloss1121_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==1, p(0) graph_options(ylabel(0(0.1)0.5) title("W HIC Investor (TMF)", size(medsmall)) ytitle("Share of area deforested (0-1)")  graphregion(color(white) lcolor(white)))
      graph save 05_figures/brdplottmf1.gph, replace 
      rdplot tmf_treeloss1121_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==0, p(0)  graph_options(ylabel(0(0.1)0.5) title("W/o HIC Investor (TMF)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/brdplottmf2.gph, replace 
      rdplot gfc_treeloss1121_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==1, p(0) graph_options(ylabel(0(0.1)0.5) title("W HIC Investor (GFC)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/brdplotgfc1.gph, replace 
      rdplot gfc_treeloss1121_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==0, p(0) graph_options(ylabel(0(0.1)0.5) title("W/o HIC Investor (GFC)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/brdplotgfc2.gph, replace 
      
      *FIG4 C
      rdplot op1317_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==1, p(0) graph_options(ylabel(0(0.05)0.2) title("W RSPO (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/crdplotop1.gph, replace 
      rdplot op1317_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==0, p(0) graph_options(ylabel(0(0.05)0.2) title("W/o RSPO (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/crdplotop2.gph, replace 
      rdplot gav_1119_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==1, p(0) graph_options(ylabel(0(0.2)0.6) title("W RSPO (Gaveau)", size(medsmall))  ytitle("Share of area with OP (0-1)" ) graphregion(color(white) lcolor(white)))
      graph save 05_figures/crdplotdu1.gph, replace 
      rdplot gav_1119_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==0, p(0) graph_options(ylabel(0(0.2)0.6) title("W/o RSPO (Gaveau)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/crdplotdu2.gph, replace 

      *FIG5 D
      rdplot tmf_treeloss1121_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==1, p(0) graph_options(ylabel(0(0.1)0.6) title("W RSPO (TMF)", size(medsmall)) ytitle("Share of area deforested (0-1)") graphregion(color(white) lcolor(white)))
      graph save 05_figures/drdplottmf1.gph, replace 
      rdplot tmf_treeloss1121_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==0, p(0)  graph_options(ylabel(0(0.1)0.6) title("W/o RSPO (TMF)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/drdplottmf2.gph, replace 
      rdplot gfc_treeloss1121_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==1, p(0) graph_options(ylabel(0(0.1)0.6) title("W RSPO (GFC)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/drdplotgfc1.gph, replace 
      rdplot gfc_treeloss1121_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==0, p(0) graph_options(ylabel(0(0.1)0.6) title("W/o RSPO (GFC)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/drdplotgfc2.gph, replace 

      *FIG4 E
      rdplot op1317_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==1, p(0) graph_options(ylabel(0(0.1)0.4) title("W MNEs (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/erdplotop1.gph, replace 
      rdplot op1317_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==0, p(0) graph_options(ylabel(0(0.1)0.4) title("W/o MNEs (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/erdplotop2.gph, replace 
      rdplot gav_1119_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==1, p(0) graph_options(ylabel(0(0.2)0.8) title("W MNEs (Gaveau)", size(medsmall))  ytitle("Share of area with OP (0-1)" ) graphregion(color(white) lcolor(white)))
      graph save 05_figures/erdplotdu1.gph, replace 
      rdplot gav_1119_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==0, p(0) graph_options(ylabel(0(0.2)0.8) title("W/o MNEs (Gaveau)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/erdplotdu2.gph, replace 

      *FIG5 F
      rdplot tmf_treeloss1121_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==1, p(0) graph_options(ylabel(0(0.1)0.5) title("W MNEs (TMF)", size(medsmall)) ytitle("Share of area deforested (0-1)") graphregion(color(white) lcolor(white)))
      graph save 05_figures/frdplottmf1.gph, replace 
      rdplot tmf_treeloss1121_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==0, p(0)  graph_options(ylabel(0(0.1)0.5) title("W/o MNEs (TMF)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/frdplottmf2.gph, replace 
      rdplot gfc_treeloss1121_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==1, p(0) graph_options(ylabel(0(0.2)0.6) title("W MNEs (GFC)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/frdplotgfc1.gph, replace 
      rdplot gfc_treeloss1121_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==0, p(0) graph_options(ylabel(0(0.2)0.6) title("W/o MNEs (GFC)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/frdplotgfc2.gph, replace 

      grc1leg  05_figures/ardplotdu1.gph 05_figures/ardplotdu2.gph 05_figures/ardplotop1.gph 05_figures/ardplotop2.gph  ///
      05_figures/crdplotdu1.gph 05_figures/crdplotdu2.gph 05_figures/crdplotop1.gph 05_figures/crdplotop2.gph       ///
     05_figures/erdplotdu1.gph 05_figures/erdplotdu2.gph 05_figures/erdplotop1.gph 05_figures/erdplotop2.gph , ///
     cols(4) legendfrom(05_figures/crdplotop1.gph)  xcommon scheme( s2gcolor )    graphregion(color(white) lcolor(white))  note("") 
      graph save 05_figures/Final/fig4_panelA.gph, replace 

      grc1leg 05_figures/brdplottmf1.gph 05_figures/brdplottmf2.gph 05_figures/brdplotgfc1.gph 05_figures/brdplotgfc2.gph ///
      05_figures/drdplottmf1.gph 05_figures/drdplottmf2.gph 05_figures/drdplotgfc1.gph 05_figures/drdplotgfc2.gph ///
       05_figures/frdplottmf1.gph 05_figures/frdplottmf2.gph   05_figures/frdplotgfc1.gph 05_figures/frdplotgfc2.gph , ///
       cols(4) legendfrom(05_figures/brdplottmf1.gph) xcommon scheme( s2gcolor) graphregion(color(white) lcolor(white))  note("")  
      graph save 05_figures/Final/fig5_panelA.gph, replace 


***APPENDIX  
**FIGURE A1
      clear all
      set more off
      version 16

      cd "C:\Users\christoph.kubitza\OneDrive - GIGA\Working Paper\CK Oil palm investors\Data\"
      use "04_master/master_data_v2.dta", replace
      bysort poly_id: asgen gavshare_2011_poly_id = gavshare_2011 , weights(gav_totalpixel)

      **Filter dataset
      *Drop deals with more than 1% OP already in 2000
      drop if gavshare_2000_poly_id>0.01      
      *With less then 1% of OP plating btw 2000 and 2011
      drop if gavshare_2011_poly_id<0.10  
     
      *FIG4 A
      rdplot op0110_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==1, p(0) graph_options(ylabel(0(0.05)0.2) title("W HIC Investor (Danylo)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/ardplotop1b2011.gph, replace 
      rdplot op0110_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==0, p(0) graph_options(ylabel(0(0.05)0.2) title("W/o HIC Investor (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/ardplotop2b2011.gph, replace 
      rdplot gav_0010_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==1, p(0) graph_options(ylabel(0(0.2)0.6) title("W HIC Investor (Gaveau)", size(medsmall)) ytitle("Share of area with OP (0-1)" )  graphregion(color(white) lcolor(white)))
      graph save 05_figures/ardplotdu1b2011.gph, replace 
      rdplot gav_0010_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==0, p(0) graph_options(ylabel(0(0.2)0.6) title("W/o HIC Investor (Gaveau)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/ardplotdu2b2011.gph, replace 

      *FIG5 B
      rdplot tmf_treeloss0010_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==1, p(0) graph_options(ylabel(0(0.1)0.5) title("W HIC Investor (TMF)", size(medsmall)) ytitle("Share of area deforested (0-1)")  graphregion(color(white) lcolor(white)))
      graph save 05_figures/brdplottmf1b2011.gph, replace 
      rdplot tmf_treeloss0010_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==0, p(0)  graph_options(ylabel(0(0.1)0.5) title("W/o HIC Investor (TMF)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/brdplottmf2b2011.gph, replace 
      rdplot gfc_treeloss0110_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==1, p(0) graph_options(ylabel(0(0.1)0.5) title("W HIC Investor (GFC)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/brdplotgfc1b2011.gph, replace 
      rdplot gfc_treeloss0110_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==0, p(0) graph_options(ylabel(0(0.1)0.5) title("W/o HIC Investor (GFC)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/brdplotgfc2b2011.gph, replace 
      
      *FIG4 C
      rdplot op0110_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==1, p(0) graph_options(ylabel(0(0.05)0.2) title("W RSPO (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/crdplotop1b2011.gph, replace 
      rdplot op0110_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==0, p(0) graph_options(ylabel(0(0.05)0.2) title("W/o RSPO (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/crdplotop2b2011.gph, replace 
      rdplot gav_0010_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==1, p(0) graph_options(ylabel(0(0.2)0.6) title("W RSPO (Gaveau)", size(medsmall))  ytitle("Share of area with OP (0-1)" ) graphregion(color(white) lcolor(white)))
      graph save 05_figures/crdplotdu1b2011.gph, replace 
      rdplot gav_0010_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==0, p(0) graph_options(ylabel(0(0.2)0.6) title("W/o RSPO (Gaveau)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/crdplotdu2b2011.gph, replace 

      *FIG5 D
      rdplot tmf_treeloss0010_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==1, p(0) graph_options(ylabel(0(0.1)0.6) title("W RSPO (TMF)", size(medsmall)) ytitle("Share of area deforested (0-1)") graphregion(color(white) lcolor(white)))
      graph save 05_figures/drdplottmf1b2011.gph, replace 
      rdplot tmf_treeloss0010_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==0, p(0)  graph_options(ylabel(0(0.1)0.6) title("W/o RSPO (TMF)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/drdplottmf2b2011.gph, replace 
      rdplot gfc_treeloss0110_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==1, p(0) graph_options(ylabel(0(0.1)0.6) title("W RSPO (GFC)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/drdplotgfc1b2011.gph, replace 
      rdplot gfc_treeloss0110_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==0, p(0) graph_options(ylabel(0(0.1)0.6) title("W/o RSPO (GFC)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/drdplotgfc2b2011.gph, replace 

      *FIG4 E
      rdplot op0110_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==1, p(0) graph_options(ylabel(0(0.1)0.4) title("W MNEs (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/erdplotop1b2011.gph, replace 
      rdplot op0110_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==0, p(0) graph_options(ylabel(0(0.1)0.4) title("W/o MNEs (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/erdplotop2b2011.gph, replace 
      rdplot gav_0010_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==1, p(0) graph_options(ylabel(0(0.2)0.8) title("W MNEs (Gaveau)", size(medsmall))  ytitle("Share of area with OP (0-1)" ) graphregion(color(white) lcolor(white)))
      graph save 05_figures/erdplotdu1b2011.gph, replace 
      rdplot gav_0010_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==0, p(0) graph_options(ylabel(0(0.2)0.8) title("W/o MNEs (Gaveau)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/erdplotdu2b2011.gph, replace 

      *FIG5 F
      rdplot tmf_treeloss0010_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==1, p(0) graph_options(ylabel(0(0.1)0.5) title("W MNEs (TMF)", size(medsmall)) ytitle("Share of area deforested (0-1)") graphregion(color(white) lcolor(white)))
      graph save 05_figures/frdplottmf1b2011.gph, replace 
      rdplot tmf_treeloss0010_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==0, p(0)  graph_options(ylabel(0(0.1)0.5) title("W/o MNEs (TMF)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/frdplottmf2b2011.gph, replace 
      rdplot gfc_treeloss0110_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==1, p(0) graph_options(ylabel(0(0.2)0.6) title("W MNEs (GFC)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/frdplotgfc1b2011.gph, replace 
      rdplot gfc_treeloss0110_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==0, p(0) graph_options(ylabel(0(0.2)0.6) title("W/o MNEs (GFC)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/frdplotgfc2b2011.gph, replace 

      grc1leg  05_figures/ardplotdu1b2011.gph 05_figures/ardplotdu2b2011.gph 05_figures/ardplotop1b2011.gph 05_figures/ardplotop2b2011.gph  ///
      05_figures/crdplotdu1b2011.gph 05_figures/crdplotdu2b2011.gph 05_figures/crdplotop1b2011.gph 05_figures/crdplotop2b2011.gph       ///
     05_figures/erdplotdu1b2011.gph 05_figures/erdplotdu2b2011.gph 05_figures/erdplotop1b2011.gph 05_figures/erdplotop2b2011.gph , ///
     cols(4) legendfrom(05_figures/crdplotop1b2011.gph)  xcommon scheme( s2gcolor )    graphregion(color(white) lcolor(white))  note("") 
      graph save 05_figures/Final/fig1a_panelA.gph, replace 

      grc1leg 05_figures/brdplottmf1b2011.gph 05_figures/brdplottmf2b2011.gph 05_figures/brdplotgfc1b2011.gph 05_figures/brdplotgfc2b2011.gph ///
      05_figures/drdplottmf1b2011.gph 05_figures/drdplottmf2b2011.gph 05_figures/drdplotgfc1b2011.gph 05_figures/drdplotgfc2b2011.gph ///
       05_figures/frdplottmf1b2011.gph 05_figures/frdplottmf2b2011.gph   05_figures/frdplotgfc1b2011.gph 05_figures/frdplotgfc2b2011.gph , ///
       cols(4) legendfrom(05_figures/brdplottmf1b2011.gph) xcommon scheme( s2gcolor) graphregion(color(white) lcolor(white))  note("")  
       graph save 05_figures/Final/fig1a_panelB.gph, replace 



**FIGURE A2
      clear all
      set more off
      version 16

      cd "C:\Users\christoph.kubitza\OneDrive - GIGA\Working Paper\CK Oil palm investors\Data\"
      use "04_master/master_data_v2.dta", replace
      bysort poly_id: asgen gavshare_2009_poly_id = gavshare_2009 , weights(gav_totalpixel)

      **Filter dataset
      *Drop deals with more than 1% OP already in 2000
      drop if gavshare_2000_poly_id>0.01      
      *With less then 1% of OP plating btw 2000 and 2011
      drop if gavshare_2009_poly_id<0.01  
     
      *FIG4 A
      rdplot op0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==1, p(0) graph_options(ylabel(0(0.05)0.2) title("W HIC Investor (Danylo)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/ardplotop1b2009.gph, replace 
      rdplot op0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==0, p(0) graph_options(ylabel(0(0.05)0.2) title("W/o HIC Investor (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/ardplotop2b2009.gph, replace 
      rdplot gav_0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==1, p(0) graph_options(ylabel(0(0.2)0.6) title("W HIC Investor (Gaveau)", size(medsmall)) ytitle("Share of area with OP (0-1)" )  graphregion(color(white) lcolor(white)))
      graph save 05_figures/ardplotdu1b2009.gph, replace 
      rdplot gav_0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==0, p(0) graph_options(ylabel(0(0.2)0.6) title("W/o HIC Investor (Gaveau)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/ardplotdu2b2009.gph, replace 

      *FIG5 B
      rdplot tmf_treeloss0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==1, p(0) graph_options(ylabel(0(0.1)0.5) title("W HIC Investor (TMF)", size(medsmall)) ytitle("Share of area deforested (0-1)")  graphregion(color(white) lcolor(white)))
      graph save 05_figures/brdplottmf1b2009.gph, replace 
      rdplot tmf_treeloss0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==0, p(0)  graph_options(ylabel(0(0.1)0.5) title("W/o HIC Investor (TMF)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/brdplottmf2b2009.gph, replace 
      rdplot gfc_treeloss0108_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==1, p(0) graph_options(ylabel(0(0.1)0.5) title("W HIC Investor (GFC)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/brdplotgfc1b2009.gph, replace 
      rdplot gfc_treeloss0108_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & investor_highinc_woSGP==0, p(0) graph_options(ylabel(0(0.1)0.5) title("W/o HIC Investor (GFC)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/brdplotgfc2b2009.gph, replace 
      
      *FIG4 C
      rdplot op0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==1, p(0) graph_options(ylabel(0(0.05)0.2) title("W RSPO (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/crdplotop1b2009.gph, replace 
      rdplot op0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==0, p(0) graph_options(ylabel(0(0.05)0.2) title("W/o RSPO (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/crdplotop2b2009.gph, replace 
      rdplot gav_0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==1, p(0) graph_options(ylabel(0(0.2)0.6) title("W RSPO (Gaveau)", size(medsmall))  ytitle("Share of area with OP (0-1)" ) graphregion(color(white) lcolor(white)))
      graph save 05_figures/crdplotdu1b2009.gph, replace 
      rdplot gav_0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==0, p(0) graph_options(ylabel(0(0.2)0.6) title("W/o RSPO (Gaveau)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/crdplotdu2b2009.gph, replace 

      *FIG5 D
      rdplot tmf_treeloss0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==1, p(0) graph_options(ylabel(0(0.1)0.6) title("W RSPO (TMF)", size(medsmall)) ytitle("Share of area deforested (0-1)") graphregion(color(white) lcolor(white)))
      graph save 05_figures/drdplottmf1b2009.gph, replace 
      rdplot tmf_treeloss0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==0, p(0)  graph_options(ylabel(0(0.1)0.6) title("W/o RSPO (TMF)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/drdplottmf2b2009.gph, replace 
      rdplot gfc_treeloss0108_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==1, p(0) graph_options(ylabel(0(0.1)0.6) title("W RSPO (GFC)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/drdplotgfc1b2009.gph, replace 
      rdplot gfc_treeloss0108_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & rspo_mill==0, p(0) graph_options(ylabel(0(0.1)0.6) title("W/o RSPO (GFC)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/drdplotgfc2b2009.gph, replace 

      *FIG4 E
      rdplot op0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==1, p(0) graph_options(ylabel(0(0.1)0.4) title("W MNEs (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/erdplotop1b2009.gph, replace 
      rdplot op0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==0, p(0) graph_options(ylabel(0(0.1)0.4) title("W/o MNEs (Danylo)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/erdplotop2b2009.gph, replace 
      rdplot gav_0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==1, p(0) graph_options(ylabel(0(0.2)0.8) title("W MNEs (Gaveau)", size(medsmall))  ytitle("Share of area with OP (0-1)" ) graphregion(color(white) lcolor(white)))
      graph save 05_figures/erdplotdu1b2009.gph, replace 
      rdplot gav_0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==0, p(0) graph_options(ylabel(0(0.2)0.8) title("W/o MNEs (Gaveau)", size(medsmall))  graphregion(color(white) lcolor(white)))
      graph save 05_figures/erdplotdu2b2009.gph, replace 

      *FIG5 F
      rdplot tmf_treeloss0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==1, p(0) graph_options(ylabel(0(0.1)0.5) title("W MNEs (TMF)", size(medsmall)) ytitle("Share of area deforested (0-1)") graphregion(color(white) lcolor(white)))
      graph save 05_figures/frdplottmf1b2009.gph, replace 
      rdplot tmf_treeloss0008_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==0, p(0)  graph_options(ylabel(0(0.1)0.5) title("W/o MNEs (TMF)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/frdplottmf2b2009.gph, replace 
      rdplot gfc_treeloss0108_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==1, p(0) graph_options(ylabel(0(0.2)0.6) title("W MNEs (GFC)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/frdplotgfc1b2009.gph, replace 
      rdplot gfc_treeloss0108_share peat_dis_km if  peat_dis_km<1 & peat_dis_km>-1 & wsupply_2021_dum==0, p(0) graph_options(ylabel(0(0.2)0.6) title("W/o MNEs (GFC)", size(medsmall)) graphregion(color(white) lcolor(white)))
      graph save 05_figures/frdplotgfc2b2009.gph, replace 

      grc1leg  05_figures/ardplotdu1b2009.gph 05_figures/ardplotdu2b2009.gph 05_figures/ardplotop1b2009.gph 05_figures/ardplotop2b2009.gph  ///
      05_figures/crdplotdu1b2009.gph 05_figures/crdplotdu2b2009.gph 05_figures/crdplotop1b2009.gph 05_figures/crdplotop2b2009.gph       ///
     05_figures/erdplotdu1b2009.gph 05_figures/erdplotdu2b2009.gph 05_figures/erdplotop1b2009.gph 05_figures/erdplotop2b2009.gph , ///
     cols(4) legendfrom(05_figures/crdplotop1b2009.gph)  xcommon scheme( s2gcolor )    graphregion(color(white) lcolor(white))  note("") 
      graph save 05_figures/Final/fig2a_panelA.gph, replace 

      grc1leg 05_figures/brdplottmf1b2009.gph 05_figures/brdplottmf2b2009.gph 05_figures/brdplotgfc1b2009.gph 05_figures/brdplotgfc2b2009.gph ///
      05_figures/drdplottmf1b2009.gph 05_figures/drdplottmf2b2009.gph 05_figures/drdplotgfc1b2009.gph 05_figures/drdplotgfc2b2009.gph ///
       05_figures/frdplottmf1b2009.gph 05_figures/frdplottmf2b2009.gph   05_figures/frdplotgfc1b2009.gph 05_figures/frdplotgfc2b2009.gph , ///
       cols(4) legendfrom(05_figures/brdplottmf1b2009.gph) xcommon scheme( s2gcolor) graphregion(color(white) lcolor(white))  note("")  
      graph save 05_figures/Final/fig2a_panelB.gph, replace 

**FIGURE A3 Parallel trends 
      *Investor
      use "04_master/master_data_panel_v2.dta", clear
      gen pixarea_000ha_op=(pixarea_m2*op_share)/10000000
      gen pixarea_000ha_tmf=(pixarea_m2*tmf_treeloss_share)/10000000
      gen gfc_treeloss_share=gfc_treeloss/gfc_treeloss_totalpixel
      gen pixarea_000ha_gfc=(pixarea_m2*gfc_treeloss_share)/10000000
      gen pixarea_millha=(pixarea_m2)/10000000000
      collapse (sum) pixarea_000ha_op pixarea_000ha_tmf pixarea_000ha_gfc pixarea_millha op_exp tmf_treeloss tmf_totalpixel op_totpixel pixarea_m2 gfc_treeloss, by(   year investor_highinc  peat_d )
     
      replace pixarea_000ha_op=. if year>=2018
      replace pixarea_000ha_tmf=. if year>=2021
      replace pixarea_000ha_gfc=. if year<=2000

      gen id=1 if peat_d==0 & investor_highinc==0
      replace id=2 if peat_d==1 & investor_highinc==0
      replace id=3 if peat_d==0 & investor_highinc==1
      replace id=4 if peat_d==1 & investor_highinc==1
      xtset id year


      label var pixarea_000ha_op "Oil palm expansion"
      label var pixarea_000ha_gfc "Tree loss (GFC data)"
      label var pixarea_000ha_tmf"Tree loss (TMF data)"

      gen pixarea_000ha_tmf_per= (pixarea_000ha_tmf/(pixarea_millha*1000))*100
      gen pixarea_000ha_op_per = (pixarea_000ha_op /(pixarea_millha*1000))*100

      tsline pixarea_000ha_tmf_per pixarea_000ha_op_per if peat_d==0 & investor_highinc==0 & year<=2000 & year>=1990,   ytitle(Loss/gain of area in %)ylabel(0(5)20)     title(W/o HIC / Outside peatland)     scheme(s2mono)    legend(label(1 "Deforestation (TMF)") label(2 "Oil palm planting (Danylo)"))     graphregion(color(white))     plotregion(color(white))     legend(region(color(white)))
      graph save 05_figures/trendsinv1.gph, replace 
      tsline  pixarea_000ha_tmf_per pixarea_000ha_op_per  if peat_d==1 & investor_highinc==0 & year<=2000 & year>=1990, ytitle(Loss/gain of area in %) ylabel(0 5 10 15 20)  title(W/o HIC / Within peatland) scheme(s2mono) legend(label(1 "Deforestation (TMF)") label(2 "Oil palm planting (Danylo)"))     graphregion(color(white))     plotregion(color(white))     legend(region(color(white)))
      graph save 05_figures/trendsinv2.gph, replace 
      tsline pixarea_000ha_tmf_per pixarea_000ha_op_per if peat_d==0 & investor_highinc==1 & year<=2000 & year>=1990, ytitle(Loss/gain of area in %) ylabel(0 5 10 15 20)  title(HIC / Outside peatland) scheme(s2mono) legend(label(1 "Deforestation (TMF)") label(2 "Oil palm planting (Danylo)"))     graphregion(color(white))     plotregion(color(white))     legend(region(color(white)))
      graph save 05_figures/trendsinv3.gph, replace 
      tsline  pixarea_000ha_tmf_per pixarea_000ha_op_per  if  peat_d==1 & investor_highinc==1 & year<=2000 & year>=1990, ytitle(Loss/gain of area in %) ylabel(0 5 10 15 20)  title(HIC / Within peatland) scheme(s2mono) legend(label(1 "Deforestation (TMF)") label(2 "Oil palm planting (Danylo)"))     graphregion(color(white))     plotregion(color(white))     legend(region(color(white)))
      graph save 05_figures/trendsinv4.gph, replace 
      grc1leg  05_figures/trendsinv1.gph 05_figures/trendsinv2.gph 05_figures/trendsinv3.gph 05_figures/trendsinv4.gph,  cols(2) legendfrom(05_figures/trendsinv1.gph)    xcommon scheme( s2gcolor  ) graphregion(color(white)) plotregion(color(white))    
      graph save 05_figures/Final/fig3a_trendinvo.gph, replace 

      *RSPO
      use "04_master/master_data_panel_v2.dta", clear
      gen pixarea_000ha_op=(pixarea_m2*op_share)/10000000
      gen pixarea_000ha_tmf=(pixarea_m2*tmf_treeloss_share)/10000000
      gen gfc_treeloss_share=gfc_treeloss/gfc_treeloss_totalpixel
      gen pixarea_000ha_gfc=(pixarea_m2*gfc_treeloss_share)/10000000
      gen pixarea_millha=(pixarea_m2)/10000000000
      collapse (sum) pixarea_000ha_op pixarea_000ha_tmf pixarea_000ha_gfc pixarea_millha op_exp tmf_treeloss tmf_totalpixel op_totpixel pixarea_m2 gfc_treeloss, by(   year rspo_mill  peat_d )
     
      replace pixarea_000ha_op=. if year>=2018
      replace pixarea_000ha_tmf=. if year>=2021
      replace pixarea_000ha_gfc=. if year<=2000

      gen id=1 if peat_d==0 & rspo_mill==0
      replace id=2 if peat_d==1 & rspo_mill==0
      replace id=3 if peat_d==0 & rspo_mill==1
      replace id=4 if peat_d==1 & rspo_mill==1
      xtset id year


      label var pixarea_000ha_op "Oil palm expansion"
      label var pixarea_000ha_gfc "Tree loss (GFC data)"
      label var pixarea_000ha_tmf"Tree loss (TMF data)"

      gen pixarea_000ha_tmf_per= (pixarea_000ha_tmf/(pixarea_millha*1000))*100
      gen pixarea_000ha_op_per = (pixarea_000ha_op /(pixarea_millha*1000))*100

      tsline pixarea_000ha_tmf_per pixarea_000ha_op_per if peat_d==0 & rspo_mill==0 & year<=2000 & year>=1990, ytitle(Loss/gain of area in %) ylabel(0 5 10 15 20)  title(No RSPO / Outside peatland) scheme(s2mono) legend(label(1 "Deforestation (TMF)") label(2 "Oil palm planting (Danylo)"))     graphregion(color(white))     plotregion(color(white))     legend(region(color(white)))
      graph save 05_figures/trendsrspo1.gph, replace 
      tsline  pixarea_000ha_tmf_per pixarea_000ha_op_per  if peat_d==1 & rspo_mill==0 & year<=2000 & year>=1990, ytitle(Loss/gain of area in %) ylabel(0 5 10 15 20)  title(No RSPO / Within peatland) scheme(s2mono) legend(label(1 "Deforestation (TMF)") label(2 "Oil palm planting (Danylo)"))     graphregion(color(white))     plotregion(color(white))     legend(region(color(white)))
      graph save 05_figures/trendsrspo2.gph, replace 
      tsline pixarea_000ha_tmf_per pixarea_000ha_op_per if peat_d==0 & rspo_mill==1 & year<=2000 & year>=1990, ytitle(Loss/gain of area in %) ylabel(0 5 10 15 20)  title(RSPO / Outside peatland) scheme(s2mono) legend(label(1 "Deforestation (TMF)") label(2 "Oil palm planting (Danylo)"))     graphregion(color(white))     plotregion(color(white))     legend(region(color(white)))
      graph save 05_figures/trendsrspo3.gph, replace 
      tsline  pixarea_000ha_tmf_per pixarea_000ha_op_per  if  peat_d==1 & rspo_mill==1 & year<=2000 & year>=1990, ytitle(Loss/gain of area in %) ylabel(0 5 10 15 20)  title(RSPO / Within peatland) scheme(s2mono) legend(label(1 "Deforestation (TMF)") label(2 "Oil palm planting (Danylo)"))     graphregion(color(white))     plotregion(color(white))     legend(region(color(white)))
      graph save 05_figures/trendsrspo4.gph, replace 
      grc1leg  05_figures/trendsrspo1.gph 05_figures/trendsrspo2.gph 05_figures/trendsrspo3.gph 05_figures/trendsrspo4.gph,  cols(2) legendfrom(05_figures/trendsrspo1.gph)    xcommon scheme( s2gcolor  ) graphregion(color(white)) plotregion(color(white))    
      graph save 05_figures/Final/fig3a_trendrspo.gph, replace 

      *MNE
      use "04_master/master_data_panel_v2.dta", clear
      gen pixarea_000ha_op=(pixarea_m2*op_share)/10000000
      gen pixarea_000ha_tmf=(pixarea_m2*tmf_treeloss_share)/10000000
      gen gfc_treeloss_share=gfc_treeloss/gfc_treeloss_totalpixel
      gen pixarea_000ha_gfc=(pixarea_m2*gfc_treeloss_share)/10000000
      gen pixarea_millha=(pixarea_m2)/10000000000
      collapse (sum) pixarea_000ha_op pixarea_000ha_tmf pixarea_000ha_gfc pixarea_millha op_exp tmf_treeloss tmf_totalpixel op_totpixel pixarea_m2 gfc_treeloss, by(   year wsupply_2021_dum  peat_d )
     
      replace pixarea_000ha_op=. if year>=2018
      replace pixarea_000ha_tmf=. if year>=2021
      replace pixarea_000ha_gfc=. if year<=2000

      gen id=1 if peat_d==0 & wsupply_2021_dum==0
      replace id=2 if peat_d==1 & wsupply_2021_dum==0
      replace id=3 if peat_d==0 & wsupply_2021_dum==1
      replace id=4 if peat_d==1 & wsupply_2021_dum==1
      xtset id year


      label var pixarea_000ha_op "Oil palm expansion"
      label var pixarea_000ha_gfc "Tree loss (GFC data)"
      label var pixarea_000ha_tmf"Tree loss (TMF data)"

      gen pixarea_000ha_tmf_per= (pixarea_000ha_tmf/(pixarea_millha*1000))*100
      gen pixarea_000ha_op_per = (pixarea_000ha_op /(pixarea_millha*1000))*100

      tsline pixarea_000ha_tmf_per pixarea_000ha_op_per if peat_d==0 & wsupply_2021_dum==0 & year<=2000 & year>=1990, ytitle(Loss/gain of area in %) ylabel(0 5 10 15 20 25 30)  title(No MNE / Outside peatland) scheme(s2mono) legend(label(1 "Deforestation (TMF)") label(2 "Oil palm planting (Danylo)"))     graphregion(color(white))     plotregion(color(white))     legend(region(color(white)))
      graph save 05_figures/trendsmne1.gph, replace 
      tsline  pixarea_000ha_tmf_per pixarea_000ha_op_per  if peat_d==1 & wsupply_2021_dum==0 & year<=2000 & year>=1990, ytitle(Loss/gain of area in %) ylabel(0 5 10 15 20 25 30)  title(No MNE / Within peatland) scheme(s2mono) legend(label(1 "Deforestation (TMF)") label(2 "Oil palm planting (Danylo)"))     graphregion(color(white))     plotregion(color(white))     legend(region(color(white)))
      graph save 05_figures/trendsmne2.gph, replace 
      tsline pixarea_000ha_tmf_per pixarea_000ha_op_per if peat_d==0 & wsupply_2021_dum==1 & year<=2000 & year>=1990, ytitle(Loss/gain of area in %) ylabel(0 5 10 15 20 25 30)  title(MNE / Outside peatland) scheme(s2mono) legend(label(1 "Deforestation (TMF)") label(2 "Oil palm planting (Danylo)"))     graphregion(color(white))     plotregion(color(white))     legend(region(color(white)))
      graph save 05_figures/trendsmne3.gph, replace 
      tsline  pixarea_000ha_tmf_per pixarea_000ha_op_per  if  peat_d==1 & wsupply_2021_dum==1 & year<=2000 & year>=1990, ytitle(Loss/gain of area in %) ylabel(0 5 10 15 20 25 30)  title(MNE / Within peatland) scheme(s2mono) legend(label(1 "Deforestation (TMF)") label(2 "Oil palm planting (Danylo)"))     graphregion(color(white))     plotregion(color(white))     legend(region(color(white)))
      graph save 05_figures/trendsmne4.gph, replace 
      grc1leg  05_figures/trendsmne1.gph 05_figures/trendsmne2.gph 05_figures/trendsmne3.gph 05_figures/trendsmne4.gph,  cols(2) legendfrom(05_figures/trendsmne1.gph)    xcommon scheme( s2gcolor  )   graphregion(color(white)) plotregion(color(white))     
      graph save 05_figures/Final/fig3a_trendmne.gph, replace 

